package classesdemo;

import static java.lang.System.out;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.TimeZone;

/*
    Calendar与SimpleDateFormat demo
    simpledateformat: M是月,mm是分
    MMM
 */

public class CalendarTest {

    public static void main(String[] args) throws ParseException {
		Calendar ct = Calendar.getInstance();
        System.out.println(ct.getTime());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
        System.out.println(sdf.format(ct.getTime())) ;

		out.println("now is: " + ct.get(Calendar.YEAR));
		
//        SimpleDateFormat sdf = new SimpleDateFormat("Y-MM-dd hh:mm:ss");
        ct.set(1975, Calendar.DECEMBER, 34, 23, 34, 45);
        System.out.println(sdf.format(ct.getTime()));
		ct.set(2012, 7, 24, 15, 50, 00);
		out.println(ct.getTime());
		ct.add(Calendar.DATE, 100);
		out.println(ct.getTime());
        
        
        //把汉字的日期转成date
        String str = "07###三月##21";
        SimpleDateFormat sdf2 = new SimpleDateFormat("y###MMM##d");
        System.out.println(sdf2.parse(str));

        
        //TimeZone
        System.out.println(Arrays.toString(TimeZone.getAvailableIDs()));
        TimeZone tz = TimeZone.getTimeZone("US/Hawaii");
        System.out.println(tz.getID() + ", " + tz.getDisplayName());
	}

}
